{include file="head" /}

{include file="menu" /}

<!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <!--state overview start-->
              
              <div class="row state-overview">
				<form action="" method="get">
                <div class="container">
                <div class="row">
                      <div class="col-lg-3 mar-10">
                        <div class="input-group">
                            <span class="input-group-addon" id="basic-addon1">订单编号</span>
                            <input type="text"  name="orderid"  class="form-control" value="{$getdata.oid?$getdata.oid:''}" placeholder="输入订单编号/订单id"/>
                        </div>
                      </div>

                      <div class="col-lg-3 mar-10">
                        <div class="input-group">
                            <span class="input-group-addon" id="basic-addon1">用户名称</span>
                            <input type="text"   class="form-control" value="{$getdata.username?$getdata.username:''}"  name="username" placeholder="昵称/姓名/手机号/编号"/>
                        </div>
                      </div>

                      <div class="col-lg-6 mar-10">
                        <div class="input-group">
                            <span class="input-group-addon" id="basic-addon1">订单时间</span>
                            <input type="text"  id="datetimepicker" class="form-control" placeholder="点击选择时间" name="starttime" value="{$getdata.starttime?$getdata.starttime:''}"/>
                            <span class="input-group-addon" id="basic-addon1">至</span>
                            <input type="text"  id="datetimepicker_end" class="form-control" placeholder="点击选择时间" name="endtime" value="{$getdata.endtime?$getdata.endtime:''}" />
                        </div>
                      </div>

                      <div class="col-lg-3 mar-10">
                        <div class="input-group">
                            <span class="input-group-addon">涨跌</span>
                            <select name="ostyle" id="" class="selectpicker show-tick form-control">
                                <option value="">默认不选</option>
                                <option {if isset($getdata['ostyle']) && $getdata['ostyle'] == 1} selected="selected" {/if} value="1">买涨</option>
                                <option {if isset($getdata['ostyle']) && $getdata['ostyle'] == 2} selected="selected" {/if} value="2">买跌</option>
                            </select>
                        </div>
                      </div>

                      <div class="col-lg-3 mar-10">
                        <div class="input-group">
                            <span class="input-group-addon">盈亏</span>
                            <select name="ploss" id="" class="selectpicker show-tick form-control">
                                <option value="">默认不选</option>
                                <option {if isset($getdata['ploss']) && $getdata['ploss'] == 1} selected="selected" {/if} value="1">赢利</option>
                                <option {if isset($getdata['ploss']) && $getdata['ploss'] == 2} selected="selected" {/if} value="2">亏损</option>
                                <option {if isset($getdata['ploss']) && $getdata['ploss'] == 3} selected="selected" {/if} value="3">无效</option>
                            </select>
                        </div>
                      </div>
                      
                      <div class="col-lg-3 mar-10">
                        <div class="input-group">
                            <span class="input-group-addon">产品</span>
                            <select name="pid" id="" class="selectpicker show-tick form-control">
                                <option value="">默认不选</option>
                                <!-- {volist name="pro" id="vo"} -->
                                <option {if isset($getdata['pid']) && $getdata['pid'] == $vo['pid']} selected="selected" {/if} value="{$vo.pid}">{$vo.ptitle}</option>
                                <!-- {/volist} -->
                                
                            </select>
                        </div>
                      </div>

                      <div class="col-lg-3 mar-10">
                        <div class="input-group">
                            <span class="input-group-addon">状态</span>
                            <select name="ostaus" id="" class="selectpicker show-tick form-control">
                                <option value="">默认不选</option>
                                <option {if isset($getdata['ostaus']) && $getdata['ostaus'] == 1} selected="selected" {/if}  value="1">建仓</option>
                                <option {if isset($getdata['ostaus']) && $getdata['ostaus'] == 2} selected="selected" {/if}  value="2">平仓</option>
                            </select>
                        </div>
                      </div>
                  </div>
                  <div class="mar-10">
                   <input type="submit" class="btn btn-success" value="搜索">
                  </div>
                </div>
                </form>
              </div>
              
              <!--state overview end-->
            
            <a href="{:url('order/orderlist')}"><button type="submit" class="btn btn-danger">搜索全部</button></a>&nbsp;&nbsp;&nbsp;&nbsp; <span class="color_red">&nbsp;&nbsp;<strong>默认为当天订单</strong></span>
            <br><br>
             <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                          <header class="panel-heading">
                              交易记录
                          </header>
                          <table class="table table-striped table-advance table-hover">
                            <thead class="ordertable">
                              <tr>
                                <th>订单编号</th>
                                <th>交易账号</th>
                                <th>用户姓名</th>
                                <th>订单时间</th>
                                <th>产品信息</th>
                                <th>状态</th>
                                <th>方向</th>
                                <th>时间/点数</th>
                                <th>建仓点位</th>
                                <th>平仓点位</th>
                                <th>委托余额</th>
                                <th>无效委托余额</th>
                                <th>有效委托余额</th>             
                                <th>实际盈亏</th>
                                <th>买后余额</th>
                                <th>归属代理商</th>
                                
                               {if $_SESSION['otype'] == 3} <th>单控操作</th>{/if}
                                
                                <th>详情</th>
                            </tr>
                          </thead>
                          <tbody>
                          <!-- {volist name="order" id="vo"} -->
                              <tr>
                                  <td>{$vo.oid}</td>
                                  <td>{$vo.username}</td>
                                  <td>{$vo.nickname}</td>
                                  <td>{$vo.buytime|date="Y-m-d H:i:s",###}</td>
                                  <td>{$vo.ptitle}</td>
                                  <td>{if $vo.ostaus==1}平仓{else/}建仓{/if}</td>
                                  {if $vo.ostyle == 0}
                                  <td class="color_red">买涨</td>
                                  {elseif $vo.ostyle == 1/}
                                  <td class="color_green">买跌</td>
                                  {/if}
                                  <td>{$vo.endprofit}{if $vo.eid==1}点{else/}秒{/if}</td>
                                  <td>{$vo.buyprice}</td>
                                  <td>
                                    {if $vo.ostaus == 1}
                                      {if $vo["buyprice"] > $vo["sellprice"]}
                                        <font color="#2fb44e" size="3">{$vo.sellprice}</font>
                                      {else/}
                                        <font color="#ed0000" size="3">{$vo.sellprice}</font>
                                      {/if}
                                    {else/}
                                        <span {if $vo.pid == 1} class="jks drop" {elseif $vo.pid == 2} class="yks drop" {elseif $vo.pid == 3} class="tks drop" {elseif $vo.pid == 4} class="zsy drop" {/if}></span>
                                    {/if}
                                  </td>

                                  <td class="color_red">¥{$vo.fee}</td>
                                  
                                  {if $vo.ploss == 0}
                                  <td class="color_red">¥{$vo.fee}</td>
                                  {else /}
                                  <td class="color_red">¥0</td>
                                  {/if}

                                  {if $vo.ploss != 0}
                                  <td class="color_red">¥{$vo.fee}</td>
                                  {else /}
                                  <td class="color_red">¥0</td>
                                  {/if}
                                  

                                  <td {if $vo.ploss > 0} class="color_red" {else /} class="color_green" {/if}>¥{$vo.ploss}</td>
                                  <td class="color_red">¥{$vo.commission}</td>

                                  <td>{$vo.managername}</td>
                                  
                                  
                                  {if $_SESSION['otype'] == 3}<td>
                                  {if $vo.ostaus!=1}
                                    <select name="ostyle" id="" class="selectpicker select_change show-tick form-control">
                                        <option {if $vo.kong_type == 0 } selected="selected" {/if} value="{$vo.oid}_0">默认</option>
                                        <option {if $vo.kong_type == 1 } selected="selected" {/if}  value="{$vo.oid}_1">盈</option>
                                        <option {if $vo.kong_type == 2 } selected="selected" {/if}  value="{$vo.oid}_2">亏</option>
                                    </select>
                                  {else/}已平仓{/if}
                                    </td>{/if}
                                    
                                    <td>
                                      <a href="{:url('order/orderinfo',array('oid'=>$vo['oid']))}"><button class="btn btn-primary btn-xs" title="点击查看"><i class="icon-list-alt"></i></button></a>
                                      
                                  </td>
                              </tr>
							<!-- {/volist} -->
                              </tbody>
                          </table>
               {if isset($noorder) && $noorder == 1} 
                          <div class="row">
                            <div class="col-lg-12">
                              <div class="noorder">
                                暂无数据
                              </div>
                            </div>
                          </div>
               {/if} 
                      </section>
                      <div>
						<div class="row state-overview">
                  <div class="col-lg-2 col-sm-2">
                      <section class="panel">
                          <div class="symbol red color_white">
                              <h5>盈亏统计</h5>
                          </div>
                          <div class="order-boo">
                              <h1 id="profit"></h1>
                          </div>
                      </section>
                  </div>
                  <div class="col-lg-2 col-sm-2">
                      <section class="panel">
                          <div class="symbol gray color_white">
                              <h5>交易手数</h5>
                          </div>
                          <div class="order-boo">
                              <h1 id="count"></h1>
                          </div>
                      </section>
                  </div>
                  <div class="col-lg-2 col-sm-2">
                      <section class="panel">
                          <div class="symbol blue color_white">
                              <h5>委托金额</h5>
                          </div>
                          <div class="order-boo">
                              <h1 id="fee"></h1>
                          </div>
                      </section>
                  </div>

                  <div class="col-lg-2 col-sm-2">
                      <section class="panel">
                          <div class="symbol red color_white">
                              <h5>有效金额</h5>
                          </div>
                          <div class="order-boo">
                              <h1 id="valid_fee"></h1>
                          </div>
                      </section>
                  </div>

                  <div class="col-lg-2 col-sm-2">
                      <section class="panel">
                          <div class="symbol terques color_white">
                              <h5>无效金额</h5>
                          </div>
                          <div class="order-boo">
                              <h1 id="invalid_fee"></h1>
                              
                          </div>
                      </section>
                  </div>
                  
                  <div class="col-lg-2 col-sm-2">
                      <section class="panel">
                          <div class="symbol gray color_white">
                              <h5>手续费</h5>
                          </div>
                          <div class="order-boo">
                              <h1 id="valid_shouxu"></h1>
                          </div>
                      </section>
                  </div>

              </div>
                      </div>
                  </div>
              </div>
              {$order->render()}
             

          </section>
      </section>
      <!--main content end-->
  </section>

{include file="foot" /}
<script>
ordersta();
//底部统计
function ordersta(){
  var formurl = "{:url('/admin/order/ordersta')}";
  var data  = '{$jsongetdata}';
  
console.log(data);
  
  $.post(formurl,data,function(data){
      if (data) {
        $('#profit').html('¥'+data.profit);
        $('#count').html(data.count+'笔');
        $('#fee').html('¥'+data.fee);
        $('#invalid_fee').html('¥'+data.invalid_fee);
        $('#valid_fee').html('¥'+data.valid_fee);
        $('#now_fee').html('¥'+data.now_fee);
        $('#valid_shouxu').html('¥'+data.valid_shouxu);
      }


    });
    
}


//时间选择器
$('#datetimepicker').datetimepicker();
$('#datetimepicker_end').datetimepicker();


$(".select_change").change(function(){
  var kong_id = $(this).val();
  if(kong_id){
    var kong_arr = kong_id.split('_');
  }
  var oid = kong_arr[0];
  var kong_type = kong_arr[1];
  var postdata = 'oid='+oid+"&kong_type="+kong_type;
  var posturl = "{:url('dankong')}";
  $.post(posturl,postdata,function(res){
    layer.msg(res.data);
  })
  
})
</script>